package com.ys.modules.system.controller;

import com.ys.common.result.Result;
import com.ys.modules.system.entity.Menu;
import com.ys.modules.system.service.MenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "菜单管理")
@RestController
@RequestMapping("/api/menu")
public class MenuController {
    @Autowired
    private MenuService menuService;

    @ApiOperation("菜单列表")
    @ApiResponses({
        @ApiResponse(code = 200, message = "返回菜单列表", response = Menu.class, responseContainer = "List")
    })
    @GetMapping("/list")
    public Result<List<Menu>> list(@ApiParam(value = "用户ID", required = false) Long userId) {
        // 实际项目应从token获取userId
        return Result.success(menuService.listByUserId(userId));
    }
} 